#! /usr/bin/python3
# coding=utf-8
# @time: 2025/10/23 19:30
# @Author:鹤川
#登录类
import time
from selenium.webdriver.common.by import By
from pages.basePage import BasePage

#继承BasePage类
class LoginPage(BasePage):
    #三个属性
    euname=(By.NAME,"username")
    epwd=(By.NAME,"password")
    ebut=(By.NAME,"submit")

    #行为：登录
    def login(self,uname='test',upwd='123456'):
        #输入用户名
        name=self.findEle(self.euname)
        self.inputText(name,uname)
        time.sleep(0.5)
        # #输入密码
        pwd=self.findEle(self.epwd)
        self.inputText(pwd,upwd)
        time.sleep(0.5)
        # #点击登录
        self.findEle(self.ebut).click()
        time.sleep(0.5)
    #成功,获取成功后的结果
    def loginOk(self):
        t=self.getELeTxt(self.findEle(self.eloginOrUname))
        return t

    #参数有空时，获取失败后的结果
    def loginErrorNone(self):
        return self.getAlertTxt()

    #获取失败后的结果
    def loginError(self):
        #获取登录失败后的标签文本值
        # t = self.getELeTxt(self.eloginOrUname)
        ele=self.findEle(self.eloginOrUname)
        t = self.getELeTxt(ele)
        return t

if __name__ == '__main__':
    from pages.loginPage import LoginPage
    lp=LoginPage()
    lp.login("test", "")

